<?php

/**
 * This is the model class for table "luasarealbambu".
 *
 * The followings are the available columns in table 'luasarealbambu':
 * @property integer $lab_id
 * @property integer $lab_kec
 * @property double $lab_areal
 * @property double $lab_jumlah
 * @property integer $lab_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $labKec
 */
class Luasarealbambu extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Luasarealbambu the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'luasarealbambu';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('lab_kec, lab_tahun', 'numerical', 'integerOnly'=>true),
			array('lab_areal, lab_jumlah', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('lab_id, lab_kec, lab_areal, lab_jumlah, lab_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'labKec' => array(self::BELONGS_TO, 'Kecamatan', 'lab_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'lab_id' => 'Lab',
			'lab_kec' => 'Lab Kec',
			'lab_areal' => 'Lab Areal',
			'lab_jumlah' => 'Lab Jumlah',
			'lab_tahun' => 'Lab Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('lab_id',$this->lab_id);
		$criteria->compare('lab_kec',$this->lab_kec);
		$criteria->compare('lab_areal',$this->lab_areal);
		$criteria->compare('lab_jumlah',$this->lab_jumlah);
		$criteria->compare('lab_tahun',$this->lab_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}